class HookMap{
    constructor(factory){
        this._map = new map();
        this._factory = factory;//用来创建hook的工厂
    }
    get(){//返回map中这个key对应的hook 只返回不创建
        return this._map.get(key)
    }
    for(key){//先创建后返回
        const hook = this.get(key);
        if (hook) return hook;
        let newHook = this._factory();
        this._map.set(key,newHook);
        return newHook;
    }
}

module.exports = HookMap;